#include<stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<string.h>

int main()
{
  //int fd = open("fdddddddd.txt", O_WRONLY | O_CREAT | O_TRUNC, 0666 );

  int fd = open("fdddddddd.txt", O_CREAT | O_APPEND | O_RDONLY, 0666 );
  const char* str = "hello world forever!";
  
  char buff[100];
  
  dup2(fd, 0);
  ssize_t s = read(0, buff, sizeof(buff));
  buff[s] = '\0';

  printf("%s", buff);



  //dup2(1, fd);
  
  //dup2(fd, 1);
  //write(1, str, strlen(str));


  return 0;
}





//int main()
//{
//  char buff[100];
//  ssize_t s = read(0, buff, sizeof(buff));
//  buff[s] = '\0';
//  printf("echo : %s", buff);
//
//  return 0;
//}

//int main()
//{
//	int fd = open("logggggg.txt", O_WRONLY | O_CREAT | O_TRUNC, 0666);
//	
//	int size_write = write(fd, "aaaaaaa", 3);	
//
//	close(fd);
//
//	return 0;
//}
